import sys
from PyQt5.QtCore import QObject,QTimerEvent
from PyQt5.QtWidgets import QApplication,QMainWindow,QWidget,QHBoxLayout,QPushButton,QToolTip
from PyQt5.QtGui import QIcon,QFont

'''
效果：实现鼠标指针放上去，显示控件提示信息QToolTip
'''

class TooltipForm(QMainWindow):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):

        QToolTip.setFont(QFont("SansSerif", 12))
        #给窗口设置提示
        self.setToolTip('今天是<b>元宵节</b>')

        self.setGeometry(800,300,512,512)
        self.setWindowTitle('设置控件提示信息')


        self.btn1 = QPushButton('鼠标放上去')
        self.btn1.setToolTip('按钮提示信息')

        #把按钮放到布局中去
        layout = QHBoxLayout()
        layout.addWidget(self.btn1)

        mainFrame = QWidget()
        mainFrame.setLayout(layout)

        #显示组件内容
        self.setCentralWidget(mainFrame)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = TooltipForm()
    window.show()
    sys.exit(app.exec_())